<?php
namespace Admin\Controller;

class BpFormRightController extends AbstractController  {
	
	protected $Form;

	public function _initialize(){
		$this->Form = D('BpFormRight');
		$RightTypeList = array(array("ID"=>"1","Name"=>"只读"),array("ID"=>"0","Name"=>"隐藏"),array("ID"=>"2","Name"=>"可写"));
		$this->assign("RightTypeList",$RightTypeList);
		$res = $this->Form->getBusienpList();
    	$this->assign("BusienpList",$res);
    	$res = $this->Form->getFormList();
    	$this->assign("formCtrList",$res);
    }
    
    public function index(){
    	$res = $this->Form->MyshowList();
		$this->assign("list",$res['list']);
    	$this->assign("page",$res['page']);
		$this->display();
    }
    
    public function add(){
    	if(IS_POST){
 			$result = $this->Form->Myadd();
 			if($result['state'] == 1 && !empty($result)){
				$this->success($result['msg']);
			}else if($result['state'] == 0 && !empty($result)){
				$this->error($result['msg']);
			}
    }else{
    		$this->display("BpFormRight/save");
    	}
    }
    
    public function edit(){
    	if(I('ID')){
			$res = $this->Form->Myshow(array("ID" => (int)I('ID')));
			$this->assign("editdata",$res);
		}
		$this->display("BpFormRight/save");
    }
    
    public function update(){
    	if(IS_POST){
    		$ControlID = (int)I("ControlID");
    		if(!empty($ControlID)){
    			$result = $this->Form->Myadd();
    		}else{
    			$result = $this->Form->Myupdata();
    		}
    		if($result['state'] == 1 && !empty($result)){
				$this->success($result['msg']);
			}else if($result['state'] == 0 && !empty($result)){
				$this->error($result['msg']);
			}
    	}
    }
    
    public function delete(){
		if(I('ID')){
			$result = $this->Form->Mydelet();
    		if($result['state'] == 1 && !empty($result)){
				$this->success($result['msg']);
			}else if($result['state'] == 0 && !empty($result)){
				$this->error($result['msg']);
			}
		}
    }
    

}